package com.eqdd.yiqidian.ui.discover.makerspace

import android.content.Context
import android.graphics.Color
import android.support.v4.content.ContextCompat
import com.eqdd.yiqidian.R
import com.eqdd.yiqidian.kotlin.BaseRecyclerViewAdapter
import kotlinx.android.synthetic.main.list_item_148.view.*
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * Created by jhj on 18-8-3.
 */
class MakerSpaceAdapter(val mContext: Context) : BaseRecyclerViewAdapter<MakerSpaceActivity.LeftItemBean>() {
    override fun onCreateView(viewType: Int): Int {
        return R.layout.list_item_150
    }

    override fun onBindViewItemViewHolder(holder: ItemViewHolder, bean: MakerSpaceActivity.LeftItemBean, position: Int) {
        holder.itemView?.let {
            it.tv_content.text = bean.label
            if (bean.isChecked) {
                it.linearLayout.setBackgroundColor(ContextCompat.getColor(mContext, R.color.light_gray))
            } else {
                it.linearLayout.setBackgroundColor(Color.WHITE)
            }

            it.onClick {
                if (!bean.isChecked)
                    (mContext as MakerSpaceActivity).leftItemOnClick(bean)
            }
        }
    }
}